cmake_minimum_required(VERSION 3.15)
project(fservice)

if(CMAKE_C_COMPILER MATCHES "arm" OR CMAKE_CXX_COMPILER MATCHES "arm")
    set(CMAKE_SYSTEM_PROCESSOR arm)
endif()

set(LIB_PATH /mnt/i/nexcloud/windowsUp/Project/Imx6ullQT/midware/lib)

message("CMAKE_SYSTEM_PROCESSOR is ${CMAKE_SYSTEM_PROCESSOR}")
if(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64")
    set(SYSTEM_NAME linux64)
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "arm")
    set(SYSTEM_NAME arm32)

elseif (CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64")
    set(SYSTEM_NAME arm64)
else()
    set(SYSTEM_NAME win32)
endif()



message("SYSTEM_NAME is ${SYSTEM_NAME}")
set(CMAKE_CXX_STANDARD 14)

add_executable(${PROJECT_NAME} main.cpp
        fservice.cpp
        fservice.h
        ../common/ftype.h
)

target_include_directories(${PROJECT_NAME} PRIVATE
        ${LIB_PATH}/fdbus/${SYSTEM_NAME}/include
        ../common/
)
target_link_libraries(${PROJECT_NAME} PRIVATE
        ${LIB_PATH}/fdbus/${SYSTEM_NAME}/lib/libcommon_base.so
        ${LIB_PATH}/fdbus/${SYSTEM_NAME}/lib/libfdbus-clib.so
)
if(CMAKE_SYSTEM_PROCESSOR MATCHES "arm")
target_include_directories(${PROJECT_NAME} PRIVATE
        ${LIB_PATH}/protobuf/${SYSTEM_NAME}/include
)
endif()

if(CMAKE_SYSTEM_PROCESSOR MATCHES "arm")
    target_include_directories(${PROJECT_NAME} PRIVATE
            ${LIB_PATH}/protobuf/${SYSTEM_NAME}/include
    )

    # 设置安装路径前缀（可选，默认在 Unix 下是 /usr/local，Windows 下是 C:/Program Files）
    set(CMAKE_INSTALL_PREFIX "/home/xqyr/linux/file/nfs/root/opt")
    message("CMAKE_INSTALL_PREFIX is ${CMAKE_INSTALL_PREFIX}")
    # 安装目标文件
    install(TARGETS ${PROJECT_NAME}
            RUNTIME DESTINATION bin     # 可执行文件安装到 ${prefix}/bin
    )
endif()
message("FDBUS_SO is ${LIB_PATH}/fdbus/${SYSTEM_NAME}/lib/libcommon_base.so")